package com.ny.demo;

public class Test1 {
    public static void main(String[] args) {
        Dog myDog = new Dog("大黄", 3, "棕");
        myDog.displayInfo();
        myDog.makeSound();
        System.out.println();
        Cat myCat = new Cat("小花", 2, "白");
        myCat.displayInfo();
        myCat.makeSound();
    }
}
class Dog {
    private String name;
    private int age;
    private String color;

    public Dog(String name, int age, String color) {
        this.name = name;
        this.age = age;
        this.color = color;
    }

    public void makeSound() {
        System.out.println(name + "汪汪叫！");
    }

    public void displayInfo() {
        System.out.println("这是一只" + color + "色的狗，名叫" + name + "，今年" + age + "岁。");
    }
}

class Cat {
    private String name;
    private int age;
    private String color;

    public Cat(String name, int age, String color) {
        this.name = name;
        this.age = age;
        this.color = color;
    }

    public void makeSound() {
        System.out.println(name + "喵喵叫！");
    }

    public void displayInfo() {
        System.out.println("这是一只" + color + "色的猫，名叫" + name + "，今年" + age + "岁。");
    }
}